<?php
	class PaymentHandlersController extends PaidListingsAppController
	{
		var $name = "PaymentHandlers";
		function beforeRender()
		{
			if(!$this->pageTitle)
			{
				$this->pageTitle = __("Payment Gateways");
			}
			parent::beforeRender();
		}
		function admin_index()
		{
			$paymentHandlers = $this->PaymentHandler->getPaymentHandlers();
			$this->set('paymentHandlers',$paymentHandlers);
		}
		
		function admin_edit($paymentHandler)
		{
			$PaymentHandler = $this->PaymentHandler->getPaymentHandlerObject($paymentHandler);
			if(!is_object($PaymentHandler))
			{
				$this->redirect(array('action'=>"index"));
			}
			$this->PaymentHandler->setPaymentHandler($PaymentHandler);
			if($this->data)
			{
				if($this->PaymentHandler->save($PaymentHandler,$this->data))
				{
					$this->successMsg(__("Payment gateway information has been saved"));
					$this->redirect(array("action"=>"index"));
				}
			}else
			{
				foreach($this->PaymentHandler->getFields() as $field)
				{
					$this->data['PaymentHandler'][$field] = $PaymentHandler->getFieldValue($field);
				}
			}
		}
	}
?>